package com.xinxin.leetcode.problem482;

/**
 * @author ShiXinXin
 * @date 2020-01-05 13:46
 */
class Solution {
    public String licenseKeyFormatting(String S, int K) {
        S = S.replace("-", "").toUpperCase();
        StringBuilder builder = new StringBuilder(S);
        int i = 1;
        while (S.length() - i * K > 0) {
            builder.insert(S.length() - (i++) * K, '-');
        }
        return String.valueOf(builder);
    }

    public static void main(String[] args) {
        System.out.println(new Solution().licenseKeyFormatting("2-5g-3-Jd4sa5as4d645asasd64sad645", 2));
    }
}
